package com.example.common.model.kafka;

/**
 * @author FanFu
 * @version 1.0
 * @date 2025/11/8 20:46
 */
import lombok.Data;
import java.time.LocalDateTime;

@Data
public class UserMessage {
    private String eventType; // REGISTER, UPDATE, DELETE
    private Long userId;
    private String username;
    private String email;
    private LocalDateTime eventTime;

    public static UserMessage createRegisterMessage(Long userId, String username, String email) {
        UserMessage message = new UserMessage();
        message.setEventType("REGISTER");
        message.setUserId(userId);
        message.setUsername(username);
        message.setEmail(email);
        message.setEventTime(LocalDateTime.now());
        return message;
    }

    public static UserMessage createUpdateMessage(Long userId, String username, String email) {
        UserMessage message = new UserMessage();
        message.setEventType("UPDATE");
        message.setUserId(userId);
        message.setUsername(username);
        message.setEmail(email);
        message.setEventTime(LocalDateTime.now());
        return message;
    }
}
